package com.practice.car.cardataapp.controller;

import com.practice.car.cardataapp.entity.rearEnd.LoginForm;
import com.practice.car.cardataapp.service.SystemManagerService;
import com.practice.car.cardataapp.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * car-data-app project
 *
 * @author FlagDied
 * @date 2020/9/2
 */
@RestController
public class LoginController {

    @Autowired
    private SystemManagerService systemManagerService;

    @PostMapping("/login")
    public R Login(@RequestBody LoginForm loginForm) {
        String name = loginForm.getUsername();
        String password = loginForm.getPassword();
        R r = R.create();
        if (name == null || password == null) {
            return r.error("用户名或密码不能为空！请检查");
        }
        r = systemManagerService.makeR(name, password);
        // TODO: 2020/9/7 0007
        return r;
    }

}
